function err = svm(X, Y, C, kernel)
%train and test using SVM and output C, p1 and error
%for i=1:5
    
    [wx, lx] = size(X);
    [wy, ly] = size(Y);
  %  XC(1:size(X,1),:)=X(randperm(size(X,1))',:); %random arrange X
   % YC(1:size(Y,1),:)=Y(randperm(size(Y,1))',:);
    Xtrain = X(1:wx/2,:);
    Xtest = X(wx/2+1:wx,:);
    Ytrain = Y(1:wy/2,:);
    Ytest = Y(wy/2+1:wy,:);

    [nsv alpha bias] = svc(Xtrain, Ytrain, kernel, C);
    err = svcerror(Xtrain,Ytrain, Xtest, Ytest, kernel, alpha, bias);
%end
